<template>
  <div class="mySelect">
    <div class="select-all">
      <div class="radio-item">
        <div
          class="radio"
          :class="{ active: checked.label == '全部' }"
          @click="selectAll()"
        ></div>
        <div class="label">全部</div>
      </div>
    </div>
    <div class="select-list">
      <div
        v-for="(item, index) in list"
        :key="index"
        class="select-list-item"
        :class="{ checked: item.label == checked.label }"
        @click="selectItem(item)"
      >
        {{ item.label }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    checked: {},
    list: {},
  },
  methods: {
    selectAll() {
      this.$emit("changeChecked", {
        label: "全部",
        value: 0,
      });
    },
    selectItem(item) {
      this.$emit("changeChecked", item);
    },
  },
};
</script>

<style lang="less" scoped>
.mySelect {
  display: flex;
  width: 100%;
}
.select-all {
  flex-shrink: 0;
  width: 90px;
  height: 55px;
  line-height: 55px;
  .radio-item {
    display: flex;
    align-items: center;
    height: 100%;
    .radio {
      flex-shrink: 0;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      border: 1px solid #ccc;
      transition: all 0.1s;
      margin-right: 15px;
      cursor: pointer;
      &:hover {
        border: 1px solid #387CF7;
      }
    }
    .label {
      color: #333;
      font-size: 14px;
    }
  }
}
.select-list {
  flex-grow: 1;
  display: flex;
  align-content: center;
  flex-wrap: wrap;
  padding: 5px 0;
  .select-list-item {
    width: 100px;
    height: 38px;
    line-height: 38px;
    text-align: center;
    margin: 0 10px;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
  }
  .checked {
    color: #fff;
    background-color: #387CF7;
    border-radius: 5px;
  }
}
.active {
  position: relative;
  background-color: #387CF7;
  &::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #fff;
  }
}
</style>